package recyclerview.zjitc.net.recyclerview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

/**
 * 1.添加依赖
 * 2.定义主xml布局 main_activity.xml
 * 3.根据需要定义RecyclerView每行所实现的xml布局
 * 4.定义一个Adapter继承Recycler.Adapyter<类名.MyVIewHolder>
 * 5.定义一个ArrayList存放在里面
 * 6.将Recycler绑定在Adapter
 */
public class MainActivity extends AppCompatActivity {
    RecyclerView mRecyclerView;
    List<String> mList_titles;
    List<String> mList_content;
    List<Integer> mList_image;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mRecyclerView = findViewById(R.id.recyclerview);
        mList_titles = new ArrayList<>();
        mList_image = new ArrayList<>();
        mList_content = new ArrayList<>();
        mList_titles.add("作品");
        mList_content.add("天气之子");
        mList_image.add(R.drawable.tianqizhizi);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setAdapter(new HomeAdapter(mList_titles, mList_content, mList_image, this));
        mRecyclerView.addItemDecoration(new DividerItemDecoration(MainActivity.this,DividerItemDecoration.VERTICAL));
    }
}
